package com.zzp.zjs_bos.web.action;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;


import com.zzp.zjs_bos.domain.Decidedzone;
import com.zzp.zjs_bos.web.action.base.BaseAction;

import cn.itcast.crm.domain.Customer;
import cn.itcast.crm.service.CustomerService;


@Controller
@Scope("prototype")
public class DecidedzoneAction extends BaseAction<Decidedzone> {
		
	@Resource
	private CustomerService customerService;
	
	
	private String[] subareaid;
	public void setSubareaid(String[] subareaid) {
		this.subareaid = subareaid;
	}

	public String pageQuery(){
		decidedService.pageQuery(pageBean);
		String[] excludes = new String[]{"subareas","decidedzones"};
		this.writePageBean2Json(pageBean, excludes);
		return NONE;
	}
	
	public String save(){
		decidedService.save(model,subareaid);
		return "list";
	}
	
	public String findCustomersNoAssociation(){
		List<Customer> list = customerService.findnoassociationCustomers();
		String[] excludes = new String[]{"station","telephone","address","decidedzone_id"};
		this.writeList2Json(list, excludes);
		return NONE;
	}
	
	public String findCustomersAssociation(){
		List<Customer> list = customerService.findhasassociationCustomers(model.getId());
		String[] excludes = new String[]{"station","telephone","address","decidedzone_id"};
		this.writeList2Json(list, excludes);
		return NONE;
	}
	
	private Integer[] customerIds;
	public void setCustomerIds(Integer[] customerIds) {
		this.customerIds = customerIds;
	}

	public void assigncustomerstodecidedzone(){
		customerService.assignCustomersToDecidedZone(customerIds, model.getId());
	}
}
